package com.jajahome.feature.user.activity;

import androidx.fragment.app.Fragment;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.jajahome.R;
import com.jajahome.base.BaseActivity;
import com.jajahome.feature.user.adapter.ChipsAdapter;
import com.jajahome.feature.user.fragment.CrowFrag;
import com.jajahome.model.CrowDetailModel;
import com.jajahome.widget.VerticalViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by tuxuesong on 2018/5/14.
 */

public class ChipsAct extends BaseActivity {

    public static String CROWID = "crowd";
    public static String MODEL = "model";
    public static String POSTAGE = "postage";
    public static String STATE = "state";
    public static String BUYCOUNT="buyCount";
    public static String MEMO ="memo";
    @BindView(R.id.ibtn_back)
    ImageButton imageButton;
    @BindView(R.id.textView2)
    TextView title;
    @BindView(R.id.viewpager)
    VerticalViewPager viewPager;
    private List<CrowDetailModel.DataEntity.CrowdFundingEntity> crowd_funding;
    private int crow_id;
    private int crow_detail_id;
    private int postage;
    private String memo;
    private List<Fragment> list;
    private ChipsAdapter adapter;
    private String type;


    @Override
    protected int getViewId() {
        return R.layout.act_crow_chips;
    }

    @Override
    protected void initEvent() {
        setListener();
        crow_id = getIntent().getIntExtra(CROWID, -1);
        postage = getIntent().getIntExtra(POSTAGE, -1);
        type = getIntent().getStringExtra(STATE);
        memo = getIntent().getStringExtra(MEMO);
        crowd_funding = (List<CrowDetailModel.DataEntity.CrowdFundingEntity>) getIntent().getSerializableExtra(MODEL);
        list = new ArrayList<>();
        for (int i = 0; i < crowd_funding.size(); i++) {
            list.add(CrowFrag.newInstance(i, crowd_funding.get(i), postage,type));
        }

        adapter = new ChipsAdapter(getSupportFragmentManager(), list);
        viewPager.setAdapter(adapter);

    }


    private void setListener() {
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        title.setText("认筹");
    }
}
